<template>
	<view class="flex-col page">
		<view class="flex-col flex-auto group">
			<view class="flex-row items-center space-x-19">
				<image class="shrink-0 image_8" :src="content.avatar_path" />
				<text class="font_1 text">{{content.nickname}}</text>
			</view>
			<view class="flex-col justify-center section_3 space-y-3">
				<view class="flex-row justify-between">
					<view class="flex-col items-start justify-center" style="min-height: 80rpx;">
						<text class="font_2 text_2" v-if="content.vip==0">您还不是会员</text>
						<text class="font_2 text_2" style="font-style: italic;" v-else>卡号{{content.vip_card}}</text>
						<text class="self-start font_3 text_3" v-if="content.vip==1">会员 {{content.vip_expire}}</text>
					</view>
					<!-- <view class="flex-col justify-start items-center section_4">
						<image class="image_9" src="/static/vip2.png" />
					</view> -->
				</view>
			</view>
			<view class="flex-row items-center group_2 space-x-16">
				<view class="section_5"></view>
				<text class="font_2">会员类型</text>
			</view>
			<view class="flex-row equal-division space-x-24">
				<view class="flex-col items-center space-y-43" @click="vipId=item.package_id" v-for="(item,index) in list" :key="index" :class="vipId==item.package_id?'equal-division-item':'equal-division-item_2'">
					<text class=" font_4 text_4">{{item.term}}天</text>
					<view class="flex-row items-baseline">
						<text class="font_6 text_7">￥</text>
						<text class="font_5 text_5">{{item.price}}</text>
					</view>
				</view>
			</view>
			<view class="flex-col justify-start items-center button" @click="toCreate">
				<text class="font_1 text_8">{{content.vip==0?'立即开通':'立即续费'}}</text>
			</view>
			<!-- <view class="flex-row items-center group_3 space-x-16">
				<view class="section_5"></view>
				<text class="font_2 text_9">会员权益</text>
			</view>
			<view class="flex-row equal-division_2">
				<view class="flex-col items-center equal-division-item_3 space-y-22">
					<image class="image_10" src="/static/vip.png" />
					<text class="font_3 text_10">至尊标识</text>
				</view>
				<view class="flex-col items-center equal-division-item_3 space-y-22">
					<image class="image_10" src="/static/vip.png" />
					<text class="font_3 text_10">至尊标识</text>
				</view>
				<view class="flex-col items-center equal-division-item_3 space-y-22">
					<image class="image_10" src="/static/vip.png" />
					<text class="font_3 text_10">至尊标识</text>
				</view>
				<view class="flex-col items-center equal-division-item_3 space-y-22">
					<image class="image_10" src="/static/vip.png" />
					<text class="font_3 text_10">至尊标识</text>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script setup>
	import {
		onShow,onLoad
	} from "@dcloudio/uni-app";
	import {
		onMounted,
		ref,
		reactive,
		onBeforeUnmount,
		getCurrentInstance
	} from "vue"
	const {
		proxy
	} = getCurrentInstance()
	let interval
	let member_id = ref('')
	let content = ref({})
	let list = ref([])
	let vipId =ref('')
	onLoad(()=>{
		
	})
	onBeforeUnmount(() => {
		clearInterval(interval);
	})
	onShow(() => {
		if (uni.getStorageSync('member_id')) {
			member_id.value = uni.getStorageSync('member_id')
			getDate()
		} else {
			member_id.value = ''
		}
	})
	const getDate = () => {
		proxy.$req.requestPOST(proxy.$api.CenterInfo.getInfo,{
			member_id:uni.getStorageSync('member_id')
		}).then(res => {
			if (res.flag == "success") {
				content.value = res.data
			}
		})
		proxy.$req.requestGET(proxy.$api.FlowInfo.vipPackage).then(res => {
			if (res.flag == "success") {
				list.value = res.data.list
				vipId.value=list.value[0].package_id
			}
		})
	}
	const toCreate = () => {
		proxy.$req.requestPOST(proxy.$api.FlowInfo.vipOrder,{
			member_id:uni.getStorageSync('member_id'),
			package_id:vipId.value
		}).then(res => {
			uni.showToast({
				title:res.message,
				icon:'none'
			})
			if (res.flag == "success") {
				let obj = {
					order_id: res.data.order_id,
					order_sn:res.data.order_sn,
					pay_amounts:res.data.pay_amounts
				}
				setTimeout(() => {
					uni.redirectTo({
						url: '/pages/payment/payment?parm=' + JSON.stringify(obj)
					})
				}, 1000)
			}
		})
	}
	
	const toIntegral =()=>{
		uni.navigateTo({
			url: '/pages/integral/integral'
		})
	}
</script>

<style scoped lang="scss">
	.page {
		background-color: #ffffff;
		width: 100%;
		overflow-y: auto;
		overflow-x: hidden;
		height: 100vh;

		.group {
			padding: 34rpx 30rpx 28rpx;
			overflow-y: auto;
			.space-x-19 {
				margin-bottom: 32rpx;
				&>view:not(:first-child),
				&>text:not(:first-child),
				&>image:not(:first-child) {
					margin-left: 19rpx;
				}
			
				.image_8 {
					width: 66rpx;
					height: 66rpx;
					border-radius: 50%;
					border: 2rpx solid #fff;
				}
			
				.text {
					color: #333333;
				}
			}
			.section_3 {
				padding: 26rpx 30rpx 22rpx;
				// background-color: #fe8100;
				background-image: url('../../static/bg2.png');
				background-size: 100% 100%;
				background-repeat: no-repeat;
				// border-radius: 20rpx;
				height: 202rpx;

				.text_2 {
					margin-left: 7rpx;
					color: #512c19;
					font-weight: 500;
					
					margin-bottom: 15rpx;
				}

				.section_4 {
					margin-right: 5rpx;
					margin-top: 10rpx;
					width: 142rpx;
					height: 126rpx;

						.image_9 {
							border-radius: 1rpx;
							width: 100%;
							height: 100%;
						}
					
				}

				.text_3 {
					margin-left: 8rpx;
					color: #ad6540;
					line-height: 23rpx;
					margin-top: 15rpx;
				}
			}

			.space-y-3 {

				&>view:not(:first-child),
				&>text:not(:first-child),
				&>image:not(:first-child) {
					margin-top: 3rpx;
				}
			}

			.group_2 {
				margin-top: 72rpx;
			}

			.space-x-16 {

				&>view:not(:first-child),
				&>text:not(:first-child),
				&>image:not(:first-child) {
					margin-left: 16rpx;
				}
			}

			.font_2 {
				font-size: 36rpx;
				font-family: PingFang SC;
				line-height: 34rpx;
				font-weight: 500;
				color: #ff7e00;
			}

			.equal-division {
				margin-top: 33rpx;
				flex-wrap: wrap;

				.equal-division-item {
					padding: 53rpx 17rpx 53rpx 21rpx;
					min-width: 214rpx;
					margin-right: 15rpx;
					margin-top: 15rpx;
					// flex: 1 1 214rpx;
					background-color: #ffffff4d;
					border-radius: 20rpx;
					height: 216rpx;
					border: solid 2rpx #ffff00;
					
					.items-baseline{
						>text{
							color: #ff4200;
						}
					}
					.text_4 {
						margin-left: 7rpx;
						color: #333333;
					}

					.text_6 {
						margin-left: 7rpx;
						// color: #ff4200;
					}
				}
				.equal-division-item_2{
					padding: 53rpx 17rpx 53rpx 21rpx;
					min-width: 214rpx;
					// flex: 1 1 214rpx;
					margin-right: 15rpx;
					margin-top: 15rpx;
					background-color: RGBA(246, 246, 246, 1);
					border-radius: 20rpx;
					height: 216rpx;
					border: solid 2rpx RGBA(246, 246, 246, 1);
				}
				.space-y-43 {

					&>view:not(:first-child),
					&>text:not(:first-child),
					&>image:not(:first-child) {
						margin-top: 43rpx;
					}
				}

				

				.font_4 {
					font-size: 26rpx;
					font-family: PingFang SC;
					line-height: 25rpx;
					color: #999999;
				}

				.font_6 {
					font-size: 26rpx;
					font-family: PingFang SC;
					line-height: 20rpx;
					color: #666666;
				}

				.font_5 {
					font-size: 48rpx;
					font-family: PingFang SC;
					line-height: 38rpx;
					font-weight: 700;
					color: #666666;
				}
			}


			.button {
				margin: 60rpx 30rpx 0;
				padding: 37rpx 0;
				background-color: #ffff00;
				background-image: linear-gradient(90deg, #f6e0b8 0%, #fdcb78 100%),
					linear-gradient(165deg, #f6e0b8 0%, #fdcb78 50%, #f9d38c 100%),
					linear-gradient(165deg, #fff2e9 0%, #ffcfab 50%, #d19f75 100%),
					linear-gradient(165deg, #fef9ef 0%, #ffdeb9 50%, #d19f75 100%),
					linear-gradient(165deg, #fef9ef 0%, #d19f75 100%);
				border-radius: 50rpx;

				.text_8 {
					color: #512c19;
				}
			}

			.font_1 {
				font-size: 32rpx;
				font-family: PingFang SC;
				line-height: 30rpx;
				font-weight: 500;
			}

			.group_3 {
				margin-top: 71rpx;

				.text_9 {
					line-height: 35rpx;
				}
			}

			.section_5 {
				background-color: #1ebdff;
				background-image: linear-gradient(0deg, #ff7e00 0%, #ffc77f 100%), linear-gradient(0deg, #1ebdff 0%, #6ed5ff 100%);
				border-radius: 4rpx;
				width: 8rpx;
				height: 24rpx;
			}

			.equal-division_2 {
				margin: 43rpx 4rpx 0;

				.equal-division-item_3 {
					flex: 1 1 170rpx;
					padding: 12rpx 0;

					.image_10 {
						border-radius: 40rpx;
						width: 80rpx;
						height: 80rpx;
					}

					.text_10 {
						line-height: 24rpx;
					}
				}

				.space-y-22 {

					&>view:not(:first-child),
					&>text:not(:first-child),
					&>image:not(:first-child) {
						margin-top: 22rpx;
					}
				}
			}

			.font_3 {
				font-size: 24rpx;
				font-family: PingFang SC;
				line-height: 25rpx;
				color: #333333;
			}
		}
	}
</style>